//
// Created by Finchen on 2025/9/4.
//

#ifndef POSITIONCONFIGDIALOG_H
#define POSITIONCONFIGDIALOG_H

#include <QDialog>
#include <QVector>

QT_BEGIN_NAMESPACE
class QTableWidget;
class QPushButton;
QT_END_NAMESPACE

class PositionConfigDialog : public QDialog {
    Q_OBJECT

public:
    explicit PositionConfigDialog(QWidget *parent = nullptr);
    ~PositionConfigDialog();

    void setPositions(const QVector<double>& positions);
    QVector<double> getPositions() const;

private slots:
    void onLoadClicked();
    void onClearClicked();
    void onAddClicked();
    void onFromToClicked();
    void onDeleteClicked();
    void onMoveUpClicked();
    void onMoveDownClicked();
    void onSortAscendingClicked();
    void onSortDescendingClicked();

private:
    void setupUI();
    void setupTable();
    void setupButtons();
    void connectSignals();
    void updateButtons();
    void addPosition(double position);
    void refreshTable();

    QTableWidget *m_tableWidget;
    QPushButton *m_loadButton;
    QPushButton *m_clearButton;
    QPushButton *m_addButton;
    QPushButton *m_fromToButton;
    QPushButton *m_deleteButton;
    QPushButton *m_moveUpButton;
    QPushButton *m_moveDownButton;
    QPushButton *m_sortAscButton;
    QPushButton *m_sortDescButton;
    QPushButton *m_okButton;
    QPushButton *m_cancelButton;

    QVector<double> m_positions;
};

#endif // POSITIONCONFIGDIALOG_H